package com.zbkj.crmeb.plat.enums;

import com.zbkj.crmeb.enums.BusinessTypeEnums;
import com.zbkj.crmeb.enums.plat.PlatPushStatusEnums;
import org.apache.commons.lang3.StringUtils;

/**
 * @author Zhangxuyang
 * @date 4/24/2024 4:50 下午
 * 抖店账户请配置 ENUM
 * - TikTokMerShopIdEnum
 */
public enum MerPlatEnums {
    BY_126(126, "", "BY", "别样", "byOrderProductHandler", "byOrderConfirmHandler", "bieYangProductTask", BusinessTypeEnums.PUSH_PRODUCT_PLAT_OF_BY,PlatPushStatusEnums.BY_UP,PlatPushStatusEnums.BY_DOWN),
    BY_OTHER(9610, "", "BY_9610", "别样(9610)", "byOrderProduct9610Handler", "byOrderConfirmHandler", "bieYangProduct9610Task", BusinessTypeEnums.PUSH_PRODUCT_PLAT_OF_BY_9610,PlatPushStatusEnums.BY_UP,PlatPushStatusEnums.BY_DOWN),
    POIZON_142(142, "lavitahk", "POIZON", "得物", "poizonOrderProductHandler", "poizonOrderConfirmHandler", "poizonProductTask", BusinessTypeEnums.PUSH_PRODUCT_PLAT_OF_DW,PlatPushStatusEnums.DW_UP,PlatPushStatusEnums.DW_DOWN),
    TIKTOK_0(18, "", "TIKTOK", "抖音", "tikTokOrderProductHandler", "", "tikTokProductTask", BusinessTypeEnums.PUSH_PRODUCT_PLAT_OF_DY,PlatPushStatusEnums.DY_UP,PlatPushStatusEnums.DY_DOWN),
    TIKTOK_150(150, "lavita", "TIKTOK", "抖音", "tikTokOrderProductHandler", "", "tikTokProductTask", BusinessTypeEnums.PUSH_PRODUCT_PLAT_OF_DY,PlatPushStatusEnums.DY_UP,PlatPushStatusEnums.DY_DOWN),
    OTHER(9999, "", "", "", "", "", "", BusinessTypeEnums.OTHER_PLAT,PlatPushStatusEnums.OTHER,PlatPushStatusEnums.OTHER),
    ;

    private final Integer merId;
    private final String spuPrefix;
    private final String code;
    private final String desc;
    private final String handle;
    private final String orderHandle;
    private final String taskHandle;
    private final BusinessTypeEnums businessType;

    private final PlatPushStatusEnums platUp;

    private final PlatPushStatusEnums platDown;

    MerPlatEnums(Integer merId, String spuPrefix, String code, String desc, String handle, String orderHandle, String taskHandle, BusinessTypeEnums businessType, PlatPushStatusEnums platUp, PlatPushStatusEnums platDown) {
        this.merId = merId;
        this.spuPrefix = spuPrefix;
        this.code = code;
        this.desc = desc;
        this.handle = handle;
        this.orderHandle = orderHandle;
        this.taskHandle = taskHandle;
        this.businessType = businessType;
        this.platUp = platUp;
        this.platDown = platDown;
    }

    public Integer getMerId() {
        return merId;
    }

    public String getSpuPrefix() {
        return spuPrefix;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public BusinessTypeEnums getBusinessType() {
        return businessType;
    }

    public String getOrderHandle() {
        return orderHandle;
    }

    public String getHandle() {
        return handle;
    }

    public String getTaskHandle() {
        return taskHandle;
    }

    public PlatPushStatusEnums getPlatUp() {
        return platUp;
    }

    public PlatPushStatusEnums getPlatDown() {
        return platDown;
    }

    public static MerPlatEnums getEnumByMerId(Integer merId) {
        if (merId <= 0) {
            return null;
        }
        for (MerPlatEnums value : MerPlatEnums.values()) {
            if (merId.equals(value.merId)) {
                return value;
            }
        }
        return null;
    }

    public static Integer getMerIdBySpu(String spu) {
        if (StringUtils.isNotBlank(spu)) {
            for (MerPlatEnums value : MerPlatEnums.values()) {
                if (StringUtils.isNotBlank(value.getSpuPrefix()) && spu.contains(value.getSpuPrefix())) {
                    return value.getMerId();
                }
            }
        }
        return -1;
    }

}
